<template>
  <div>
    <el-form :model="tbuser" status-icon ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="账号" prop="账号">
        <el-input type="text" v-model="tbuser.uname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="密码">
        <el-input type="password" v-model="tbuser.upass" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm()">提交</el-button>
        <el-button @click="resetForm()">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  export default {
    data(){
      return{
        tbuser:{

        },
      }
    },
    methods:{
      submitForm(){
        this.$http.post(`/users/checkLogin`,this.tbuser).
        then(res=>{
          if(res.data.falg){
            this.$message.success("登录成功");
            window.sessionStorage.setItem("token",res.data.data);
            this.$router.push("goodslist");
          }else {
            this.$message.error("账号或密码错误请重新登录");
            this.tbuser={};
          }
        }).catch(err=>{
          console.log(err);

        })

      },
      resetForm(){
        this.tbuser={};
      }
    },
    created() {

    }

  }
</script>

<style>

</style>